<template>
    <div>
        <div class="header-info">
            <p>首页设置</p>
        </div>
        <div class="title">热品</div>
        <div class="hot">
            <a>
                <ref-product v-model="json.hot1" @change="change" id="hot1">选择</ref-product>
            </a>
            <div class="sect">
                <div>
                    <a>
                        <ref-product v-model="json.hot2" @change="change" id="hot2">选择</ref-product>
                    </a>
                    <a>
                        <ref-product v-model="json.hot3" @change="change" id="hot3">选择</ref-product>
                    </a>
                </div>
                <div>
                    <a>
                        <ref-product v-model="json.hot4" @change="change" id="hot4">选择</ref-product>
                    </a>
                    <a>
                        <ref-product v-model="json.hot5" @change="change" id="hot5">选择</ref-product>
                    </a>
                </div>
            </div>
        </div>

        <div class="title">新品</div>
        <div style="display: flex;">
            <ref-product v-model="json.new1" @change="change" id="new1" style="margin:5px;">
                选择
            </ref-product>
            <ref-product v-model="json.new2" @change="change" id="new2" style="margin:5px;">
                选择
            </ref-product>
        </div>

        <div class="title">近品</div>
        <div style="display: flex;">
            <ref-product v-model="json.recent1" @change="change" id="recent1" style="margin:5px;">
                选择
            </ref-product>
            <ref-product v-model="json.recent2" @change="change" id="recent2" style="margin:5px;">
                选择
            </ref-product>
            <ref-product v-model="json.recent3" @change="change" id="recent3" style="margin:5px;">
                选择
            </ref-product>
            <ref-product v-model="json.recent4" @change="change" id="recent4" style="margin:5px;">
                选择
            </ref-product>
        </div>
    </div>
</template>

<script>
    import RefProduct from "../common/RefProduct"

    export default ({
        components: {
            RefProduct,
        },
        data() {
            return {json: {}}
        },
        mounted() {
            this.$http.post("/info/home/getData").then(res => {
                this.json = res.data.data;
            })
        },
        methods: {
            change(product, uid) {
                this.$http.post("/info/home/set", {field: uid,  productId: product.id});
            }
        }
    })
</script>

<style scoped>

    .hot {
        display: flex;
        justify-content: center;
        align-items: flex-end;
        margin-top: 3rem;
    }

    .hot > a {
        display: flex;
        height: 18rem;
        width: 30rem;
        margin: 1rem;
    }

    .hot .sect {
        display: block;
    }

    .hot .sect div {
        display: flex;
    }

    .hot > div a {
        width: 12rem;
        height: 8rem;
        margin: 1rem;
    }

    .hot a {
        background-color: burlywood;
        display: flex;
        align-items: center;
        justify-content: center;
    }
</style>
